home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreateWrap.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.9 KB  |  342 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct 12, 1998
  22. //
  23. //  Description:
  24. //      This script sets up the Create Wrap dialog box
  25. //
  26. //  Input Arguments:
  27. //      None.
  28. //
  29. //  Return Value:
  30. //      None.
  31. //
  32.  
  33. proc setOptionVars (int $forceFactorySettings)
  34. {
  35.     // Limit influence area by default is set to false
  36.     //
  37.     if ( $forceFactorySettings || !`optionVar -exists limitInfluence`) {
  38.         optionVar -intValue limitInfluence 0;
  39.     }
  40.  
  41.     // Weight threshold
  42.     //
  43.     if ( $forceFactorySettings || !`optionVar -exists weightThreshold` ) {
  44.         optionVar -floatValue weightThreshold 0.0;
  45.     }
  46.  
  47.     // Max Distance
  48.     //
  49.     if ( $forceFactorySettings || !`optionVar -exists maxDistance` ) {
  50.         optionVar -floatValue maxDistance 1.0;
  51.     }
  52.  
  53. }
  54.  
  55. //
  56. //  Procedure Name:
  57. //      createWrapSetup
  58. //
  59. //  Description:
  60. //        Update the state of the option box UI to reflect the option values.
  61. //
  62. //  Input Arguments:
  63. //      parent               - Top level parent layout of the option box UI.
  64. //                             Required so that UI object names can be 
  65. //                             successfully resolved.
  66. //
  67. //        forceFactorySettings - Whether the option values should be set to
  68. //                             default values.
  69. //
  70. //  Return Value:
  71. //      None.
  72. //
  73. global proc createWrapSetup (string $parent, int $forceFactorySettings)
  74. {
  75.     // Retrieve the option settings
  76.     //
  77.     setOptionVars( $forceFactorySettings );
  78.     
  79.     setParent $parent;
  80.     
  81.     // Query the optionVar's and set the values into the controls
  82.     //
  83.     int $limitInfluence = `optionVar -query limitInfluence`;
  84.     checkBoxGrp -e -value1 $limitInfluence liWidget;
  85.  
  86.     // Weight threshold
  87.     //
  88.     if (`floatSliderGrp -exists wtWidget`){
  89.         floatSliderGrp -edit
  90.             -value `optionVar -query weightThreshold`
  91.             wtWidget;
  92.     }
  93.     
  94.     // max distance
  95.     //
  96.     if (`floatSliderGrp -exists mdWidget`){
  97.         floatSliderGrp -edit
  98.             -value `optionVar -query maxDistance`
  99.             mdWidget;
  100.         if ($limitInfluence)
  101.             floatSliderGrp -e -enable 1 mdWidget;
  102.         else
  103.             floatSliderGrp -e -enable 0 mdWidget;
  104.     }
  105.     
  106. }
  107.  
  108.  
  109. //
  110. //  Procedure Name:
  111. //      createWrapCallback
  112. //
  113. //  Description:
  114. //        Update the option values with the current state of the option box UI.
  115. //
  116. //  Input Arguments:
  117. //      parent - Top level parent layout of the option box UI.  Required so
  118. //               that UI object names can be successfully resolved.
  119. //
  120. //        doIt   - Whether the command should execute.
  121. //
  122. //  Return Value:
  123. //      None.
  124. //
  125. global proc createWrapCallback (string $parent, int $doIt)
  126. {
  127.     setParent $parent;
  128.     
  129.     optionVar -intValue limitInfluence `checkBoxGrp -q -value1 liWidget`;
  130.  
  131.     // Weight threshold
  132.     //
  133.     if (`floatSliderGrp -exists wtWidget`) {
  134.         optionVar -floatValue weightThreshold
  135.             `floatSliderGrp -query -value wtWidget`;
  136.     }
  137.  
  138.     // Max distance
  139.     //
  140.     if (`floatSliderGrp -exists mdWidget`) {
  141.         optionVar -floatValue maxDistance
  142.             `floatSliderGrp -query -value mdWidget`;
  143.     }
  144.  
  145.     if ($doIt) {
  146.         performCreateWrap false; 
  147.         addToRecentCommandQueue "performCreateWrap false" "CreateWrap";
  148.     }
  149. }
  150.  
  151.  
  152. global proc createWrapOptions ()
  153. {
  154.     // Name of the command for this option box 
  155.     //
  156.     string $commandName = "createWrap";
  157.  
  158.     // Build the option box "methods"
  159.     //
  160.     string $callback = ($commandName + "Callback");
  161.     string $setup = ($commandName + "Setup");
  162.     
  163.     //    STEP 1:  Get the option box.
  164.     //    ============================
  165.     //
  166.     //    The value returned is the name of the layout to be used as
  167.     //    the parent for the option box UI.
  168.     //
  169.     string $layout = getOptionBox();
  170.     setParent $layout;
  171.     
  172.     //    STEP 2:  Pass the command name to the option box.
  173.     //    =================================================
  174.     //
  175.     //    Any default option box behaviour based on the command name is set 
  176.     //    up with this call.  For example, updating the 'Help' menu item with
  177.     //    the name of the command.
  178.     //
  179. //    setOptionBoxCommandName("performWrap");
  180.     
  181.     //    STEP 3:  Activate the default UI template.
  182.     //    ==========================================
  183.     //
  184.     //    Activate the default UI template so that the layout of this 
  185.     //    option box is consistent with the layout of the rest of the 
  186.     //    application.
  187.     //
  188.     setUITemplate -pushTemplate DefaultTemplate;
  189.  
  190.     //    STEP 4: Create option box contents.
  191.     //    ===================================
  192.     //    
  193.     //    This, of course, will vary from option box to option box.    
  194.     
  195.     //    Turn on the wait cursor.
  196.     //
  197.     waitCursor -state 1;
  198.  
  199.     tabLayout -tabsVisible 0 -scrollable 1;
  200.     
  201.     string $parent = `columnLayout -adjustableColumn 1`;
  202.  
  203.     floatSliderGrp -label "Weight Threshold" -minValue 0 -maxValue 1.0 -pre 2 wtWidget ;
  204.  
  205.     checkBoxGrp
  206.         -label "Limit Influence Area"
  207.         -label1 "Use Max Distance"
  208.         -numberOfCheckBoxes 1
  209.          -on1 "floatSliderGrp -e -enable 1 mdWidget"
  210.          -of1 "floatSliderGrp -e -enable 0 mdWidget"
  211.         liWidget;
  212.  
  213.  
  214.     floatSliderGrp -label "Max Distance" -minValue 0.01 -maxValue 50.0 -fieldMaxValue 1000.0 -enable (`checkBoxGrp -q -v1 liWidget`) -pre 2 mdWidget;
  215.  
  216.     //    Turn off the wait cursor.
  217.     //
  218.     waitCursor -state 0;
  219.     
  220.     //    Step 5: Deactivate the default UI template.
  221.     //    ===========================================
  222.     //
  223.     setUITemplate -popTemplate;
  224.  
  225.     //    Step 6: Customize the buttons.  
  226.     //    ==============================
  227.     //
  228.     //    Provide more descriptive labels for the buttons.  This is not 
  229.     //    necessary, but in some cases, for example, a button labelled 
  230.     //    'Create' may be more meaningful to the user than one labelled
  231.     //    'Apply'.
  232.     //
  233.     //    Disable those buttons that are not applicable to the option box.
  234.     //
  235.     //    Attach actions to those buttons that are applicable to the option
  236.     //    box.  Note that the 'Close' button has a default action attached 
  237.     //    to it that will hide the window.  If a a custom action is
  238.     //    attached to the 'Close' button then be sure to call the 'hide the
  239.     //    option box' procedure within the custom action so that the option
  240.     //    box is hidden properly.
  241.  
  242.     //    'Apply' button.
  243.     //
  244.     string $applyBtn = getOptionBoxApplyBtn();
  245.     button -edit -l "Create"
  246.         -command ($callback + " " + $parent + " " + 1)
  247.         $applyBtn;
  248.  
  249.     //    'Save' button.
  250.     //
  251.     string $saveBtn = getOptionBoxSaveBtn();
  252.     button -edit
  253.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  254.         $saveBtn;
  255.  
  256.     //    'Reset' button.
  257.     //
  258.     string $resetBtn = getOptionBoxResetBtn();
  259.     button -edit 
  260.         -command ($setup + " " + $parent + " " + 1)
  261.         $resetBtn;
  262.  
  263.     //    Step 7: Set the option box title.
  264.     //    =================================
  265.     //
  266.     setOptionBoxTitle("Create Wrap Options");
  267.  
  268.     //    Step 8: Customize the 'Help' menu item text.
  269.     //    ============================================
  270.     //
  271.     setOptionBoxHelpTag( "CreateWrap" );
  272.  
  273.     //    Step 9: Set the current values of the option box.
  274.     //    =================================================
  275.     //
  276.     eval (($setup + " " + $parent + " " + 0));    
  277.     
  278.     //    Step 10: Show the option box.
  279.     //    =============================
  280.     //
  281.     showOptionBox();
  282. }
  283.  
  284. proc string assembleCmd ()
  285. {
  286.     string $cmd;
  287.  
  288.     setOptionVars( false );
  289.     
  290.     $cmd = "doWrapArgList \"2\" { \"1\",";
  291.  
  292.     float $thresh = `optionVar -query weightThreshold`;
  293.     $cmd = $cmd + "\"" + $thresh + "\",";
  294.  
  295.     int $limitInfl = `optionVar -q limitInfluence`;
  296.     if ($limitInfl == 1)
  297.         $cmd = $cmd + "\"" + `optionVar -query maxDistance` + "\"";
  298.     else
  299.         $cmd = $cmd + "\"0.0\"";
  300.  
  301.     $cmd = $cmd + " }";
  302.     return $cmd;
  303. }
  304.  
  305. global proc string performCreateWrap (int $action)
  306. //
  307. // The action variable means
  308. //        0 - do the command
  309. //        1 - show the option box
  310. //        2 - return the drag command
  311. {
  312.     string $cmd = "";
  313.  
  314.     switch ($action) {
  315.         case 0: // Execute the command
  316.             // Retrieve the option settings
  317.             //
  318.             setOptionVars (false);
  319.  
  320.             // Get the command and print it in the command window
  321.             $cmd = `assembleCmd`;
  322.             
  323.             // Execute the command with the option settings
  324.             eval($cmd);
  325.  
  326.             break;
  327.         case 1:  // Do the option box
  328.             createWrapOptions;
  329.             break;
  330.         case 2: // Return the drag string
  331.             // Retrieve the option settings
  332.             //
  333.             setOptionVars (false);
  334.  
  335.             // Get the command
  336.             $cmd = `assembleCmd`;
  337.  
  338.             break;
  339.     }
  340.     return $cmd;
  341. }
  342.